<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String basePath = request.getScheme() + "://" + request.getServerName()
            + ":" + request.getServerPort() + request.getContextPath() + "/";

    //通过字符串拼接方式完成指定<base>标签内容的拼接
%>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>比较好看的登录页面</title>
    <base href="<%=basePath%>"/>
    <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="css/indexstyle.css">
    <script src="/reiCode/js/jquery-3.5.1.js" type="text/javascript"></script>
</head>
<body>
<section>
    <div class="container">
        <div class="user signinBx">
            <div class="imgBx"><img src="image/asu.jpg"></div>
            <div class="formBx">
                <form action="user/login.do" method="post"
                      onsubmit="return logincheck();">
                    <h2>Sign In</h2>
                    <input type="text" placeholder="Username" name="username" id="loginname">
                    <input type="password" placeholder="Password" name="userpwd" id="loginpwd">
                    <input type="submit" value="Login">
                    <p class="signup">Don't have an account? <a onclick="toggleForm();">Sign up.</a></p><br><br><br>
                    <p class="signup">@Asu Character design:@yaneyamai</p>
                    <p class="signup">Illustration by @goruko_jp</p>

                </form>
            </div>
        </div>
        <div class="user signupBx">
            <div class="formBx">
                <form action="user/registerUser.do" method="post"
                      onsubmit="return regicheck();">
                    <h2>Create an account</h2>
                    <input type="text" placeholder="Username" name="username" id="registername">
                    <input type="password" placeholder="Create Password" name="userpwd" id="registerpwd">
                    <input type="password" placeholder="Confirm Password">
                    <input type="submit" value="Sign Up">
                    <p class="signup">Already have an account? <a onclick="toggleForm();">Sign in.</a></p><br><br><br>
                    <p class="signup">@Aru Character design:@yaneyamai</p>
                </form>
            </div>
            <div class="imgBx"><img src="image/aru.jpg"></div>
        </div>
    </div>
</section>
<script>
    function toggleForm() {
        section = document.querySelector('section');
        container = document.querySelector('.container');
        container.classList.toggle('active');
        section.classList.toggle('active');
    }

    function logincheck() {
        var resn = $('#loginname').val();
        var resp = $('#loginpwd').val();
        resn = $.trim(resn);
        resp = $.trim(resp);
        if (resn == "" || resp == "") {
            alert("用户名或密码不能为空!");
            return false;
        }
    }

    function regicheck() {
        var resn = $('#registername').val();
        var resp = $('#registerpwd').val();
        resn = $.trim(resn);
        resp = $.trim(resp);
        if (resn == "" || resp == "") {
            alert("用户名或密码不能为空!");
            return false;
        }
    }

</script>
</body>
</html>
